<template>
    <van-nav-bar title="退货详情" left-text="" left-arrow @click-left="goBack" />
    <section class="aui-flexView">
        <!-- 订单详细 -->
        <section class="aui-scrollView">
            <!-- 订单状态 -->
            <div class="aui-pay-change">
                <div class="aui-flex">
                    <div class="aui-flex-box">
                        <h3>{{ detail.status_text }}</h3>
                    </div>
                    <div class="aui-pay-zfb">
                        <img src="/assets/images/icon-zfb.png" alt="" />
                    </div>
                </div>
            </div>

            <!-- 退货地址 -->
            <div class="aui-flex">
                <div style="font-size: 16px">退货地址：</div>
                <div class="aui-flex-box">
                    <h3>
                        {{ detail.refund.company }} <em>{{ detail.refund.mobile }}</em>
                    </h3>
                    <p>{{ detail.refund.address }}</p>
                </div>
            </div>

            <!-- 退货理由 -->
            <div class="aui-flex">
                <div style="font-size: 16px">退货理由：</div>
                <div class="aui-flex-box">
                    {{ detail.business_reason }}
                </div>
            </div>

            <!-- 寄件地址 -->
            <div class="aui-flex" v-if="detail.backinfo">
                <div style="font-size: 16px">寄件地址：</div>
                <div class="aui-flex-box">
                    <h3>
                        {{ detail.backinfo.contact }} <em>{{ detail.backinfo.phone }}</em>
                    </h3>
                    <p>{{ detail.backinfo.region_text }}{{ detail.backinfo.address }}</p>
                </div>
            </div>

            <!-- 商家协商 -->
            <div class="aui-flex" v-if="detail.admin_reason">
                <div style="font-size: 16px">商家协商：</div>
                <div class="aui-flex-box">
                    {{ detail.admin_reason }}
                </div>
            </div>

            <!-- 订单商品 -->
            <div class="aui-commodity-bg">
                <div class="item" v-for="item in detail.info">
                    <div class="aui-flex">
                        <div class="aui-commodity-img">
                            <img :src="item.product.thumbs_text" />
                        </div>
                        <div class="aui-flex-box">
                            <h4 class="van-ellipsis">商品名称：{{ item.product.name }}</h4>
                            <p>商品单价：￥{{ item.price }}</p>
                            <span class="aui-barter-time">七天退换</span>
                        </div>
                        <div>
                            <h5>￥{{ item.total }}</h5>
                            <p class="aui-sml-text">X {{ item.pronum }}</p>
                        </div>
                    </div>

                    <div style="text-align: right" v-if="!item.rate && detail.status == '3'">
                        <van-button type="warning" size="small" @click="toRatePeage(item.id)">评价</van-button>
                    </div>
                </div>
            </div>

            <!-- 退货物流信息 -->
            <van-steps direction="vertical" :active="0">
                <van-step v-for="(item,index) in detail.backinfo.express" :key="index">
                    <h3>{{ item.status }}</h3>
                    <p>{{ item.time }}</p>
                </van-step>
            </van-steps>
        </section>
    </section>
</template>
<script setup>
const { proxy } = getCurrentInstance()
const goBack = () => { proxy.$router.push('/order/index') }
const LoginUser = reactive(proxy.$cookies.get('LoginUser') ? proxy.$cookies.get('LoginUser') : {})
const orderid = proxy.$route.query.orderid ? proxy.$route.query.orderid : 0;
const detail = ref({
    business: {},
    address: {},
    refund: {},
    backinfo: {}
})
onBeforeMount(() => {
    getOrderInfoData()
})
const getOrderInfoData = async () => {
    let result = await Api.orderInfo({
        busid: LoginUser.id,
        orderid: orderid
    });

    if (result.code == 1) {
        detail.value = result.data
    }
}
const toRatePeage = (orderproid) => {
    proxy.$router.push({
        path: '/order/rate',
        query: {
            orderid: orderid,
            orderproid: orderproid
        }
    })
}
</script>
<style>
@import url('/assets/css/info.css');
</style>